package org.dydl.controller.system;

import javax.servlet.http.HttpSession;

import org.dydl.common.dto.ResponseMessage;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/account")
public class AccountManagementController {

	//@Autowired
	//private ISysUserService userService;

	@RequestMapping(value = "/changepwd", method = RequestMethod.POST)
	public @ResponseBody ResponseMessage success(String originPwd, String newPwd, HttpSession session) {
		ResponseMessage msg = new ResponseMessage(false);

		// Search search = new Search();
		// search.addFilterEqual("userName", session.getAttribute("userName"));
		// @SuppressWarnings("unchecked")
		// SysUser user = ((List<SysUser>) userService.search(search).getData()).get(0);
		// if (!user.getPassword().equals(MD5.encode(originPwd.getBytes()))) {
		// msg.setData("原密码错误！");
		// return msg;
		// }
		//// if (LoginUtil.checkPassword(newPwd) < 0) {
		//// msg.setData("新密码过于简单");
		//// return msg;
		//// }
		// user.setPassword(MD5.encode(newPwd.getBytes()));
		// userService.save(user);
		msg.setSuccess(true);
		msg.setData("更新成功");
		return msg;
	}
}
